package linuxbox.common;

import linuxbox.common.bean.*;
import linuxbox.exception.*;

public class BoxConfigUtil
{
  //For Module configuration
  public static void removeModuleConfigEntry(String module, String category, String name)
              throws LinuxboxException
  {
    BoxConfigEntryBean bean = new BoxConfigEntryBean(null);
    bean.setValues(module, category, name, null);
  }

//For single entry
  public static String getModuleConfigValue(String module, String category, String name)
                throws LinuxboxException
  {
    BoxConfigEntryBean bean = new BoxConfigEntryBean(null);
    return bean.getValue(module, category, name);
  }

  public static void setModuleConfigValue(String module, String category, String name, String value)
              throws LinuxboxException
 {
    BoxConfigEntryBean bean = new BoxConfigEntryBean(null);
    bean.setValue(module, category, name, value);
  }

//For Multiple entries, you have to get all the values, modify them and set them back
  public static void setModuleConfigValues(String module, String category, String name, String[] values)
              throws LinuxboxException
  {
    BoxConfigEntryBean bean = new BoxConfigEntryBean(null);
    bean.setValues(module, category, name, values);
  }

  public static String[] getModuleConfigValues(String module, String category, String name)
                  throws LinuxboxException
  {
    BoxConfigEntryBean bean = new BoxConfigEntryBean(null);
    return bean.getValues(module, category, name);
  }


  //For User configuration
  public static void removeUserConfigEntry(int UserID, String module, String category, String name)
              throws LinuxboxException
  {
    BoxUserConfigEntryBean bean = new BoxUserConfigEntryBean(null);
    bean.setValues(UserID, module, category, name, null);
  }

//For single entry
  public static String getUserConfigValue(int UserID, String module, String category, String name)
                throws LinuxboxException
  {
    BoxUserConfigEntryBean bean = new BoxUserConfigEntryBean(null);
    return bean.getValue(UserID, module, category, name);
  }

  public static void setUserConfigValue(int UserID, String module, String category, String name, String value)
              throws LinuxboxException
  {
    BoxUserConfigEntryBean bean = new BoxUserConfigEntryBean(null);
    bean.setValue(UserID, module, category, name, value);
  }

//For Multiple entries, you have to get all the values, modify them and set them back
  public static void setUserConfigValues(int UserID, String module, String category, String name, String[] values)
              throws LinuxboxException
  {
    BoxUserConfigEntryBean bean = new BoxUserConfigEntryBean(null);
    bean.setValues(UserID, module, category, name, values);
  }

  public static String[] getUserConfigValues(int UserID, String module, String category, String name)
                  throws LinuxboxException
  {
    BoxUserConfigEntryBean bean = new BoxUserConfigEntryBean(null);
    return bean.getValues(UserID, module, category, name);
  }

//For Admin
  public static void removeModuleConfig(String module)
              throws LinuxboxException
  {
    BoxConfigEntryBean bean = new BoxConfigEntryBean(null);
    bean.removeModuleConfig(module);
  }

  public static void removeUserConfig(int UserID)
              throws LinuxboxException
  {
    BoxUserConfigEntryBean bean = new BoxUserConfigEntryBean(null);
    bean.removeUserConfig(UserID);
  }
}

